package ac.github.os.internal.core.holder.player

import ac.github.os.api.common.entity.EntityAdapter
import ac.github.os.internal.core.holder.EntityCompatible
import org.bukkit.event.inventory.InventoryClickEvent

open class PlayerClickInventory(
    override val event: InventoryClickEvent
) : EntityCompatible<InventoryClickEvent>() {

    override val namespace: String
        get() = "player click inventory"

    override fun variable(string: String): String {
        return when (string) {
            "slot" -> event.slot.toString()
            "raw-slot" -> event.rawSlot.toString()
            "action" -> event.action.name
            "click-type" -> event.click.name
            "slot-type" -> event.slotType.name
            "view:title" -> event.view.title
            else -> super.variable(string)
        }
    }

    override fun entity(): EntityAdapter {
        val entity = event.whoClicked
        return entity.adapt()
    }
}